﻿using System;
using System.Windows.Forms;

namespace FinanceManager
{
    public partial class AddNewWork : Form
    {
        public AddNewWork()
        {
            InitializeComponent();

            dtpstart.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
            dtpstart.CustomFormat = "yyyy/MM/dd";
        }

        private void AddNewWork_Load(object sender, EventArgs e)
        {
            cbbWorker.DataSource = workerTableAdapter1.GetData();
            cbbWorker.ValueMember = "序号";
            cbbWorker.DisplayMember = "工人名";
        }

        private void btnAddWork_Click(object sender, EventArgs e)
        {
            if (workListTableAdapter1.AddWorkItem(long.Parse(cbbWorker.SelectedValue.ToString()), Convert.ToDateTime(dtpstart.Text), tbcomme.Text) == 1)
            {
                MessageBox.Show("新工期添加成功！");
            }
        }

        private void AddNewWork_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }
    }
}
